﻿using AbpToDomain.View;
using CommunityToolkit.Mvvm.Input;
using NewWms.Apiservice;
using NewWms.Apiservice.Dto;
using Prism.Mvvm;
using Prism.Regions;
using Reconstruct_Desktop.Apiservice.Dto;
using Reconstruct_Desktop.Apiservice.InPut;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Reconstruct_Desktop.ViewModels.OrderManageViewModel
{
    public partial class PutInOrderManageViewModel : BindableBase, INavigationAware
    {



        private readonly IViewService_Client viewService;
        private readonly IBaseService_Client baseService;

        private InPut_ViewService11_Client inPut_ViewService11;
        public InPut_ViewService11_Client InPut_ViewService11
        {
            get { return inPut_ViewService11; }
            set { inPut_ViewService11 = value; RaisePropertyChanged(); }
        }
        private List<PutInOrderDto> putInOrderDtos;
        public List<PutInOrderDto> PutInOrderDtos
        {
            get { return putInOrderDtos; }
            set { putInOrderDtos = value; RaisePropertyChanged(); }
        }
        private long count;
        public long Count
        {
            get { return count; }
            set { count = value; RaisePropertyChanged(); }
        }
        private long pagecount;
        public long PageCount
        {
            get { return pagecount; }
            set { pagecount = value; RaisePropertyChanged(); }
        }
        public PutInOrderManageViewModel()
        {
           viewService = new ViewService_Client();
           baseService = new BaseService_Client();
           InPut_ViewService11=new InPut_ViewService11_Client();
           PutInOrderDtos=new List<PutInOrderDto>();
           InPut_ViewService11.PageIndex = 1;
           InPut_ViewService11.PageSize = 50;
        }

        [RelayCommand]
        private async void View_PutInOrder()
        {
            Tuple<List<PutInOrderDto>, long?, long?> tuple = await viewService.View_PutInOrder(InPut_ViewService11);
            if (tuple == null)
            {
                return;
            }
            PutInOrderDtos = tuple.Item1;
            Count = (long)tuple.Item2;
            PageCount = (long)tuple.Item3;
        }

        //主页设置
        private string title = "入库清单";
        public string Title
        {
            get { return title; }
            set { title = value; RaisePropertyChanged(); }
        }
        public bool IsNavigationTarget(NavigationContext navigationContext)
        {
            return true;
        }
        public void OnNavigatedFrom(NavigationContext navigationContext)
        {
            
        }
        public void OnNavigatedTo(NavigationContext navigationContext)
        {
            View_PutInOrder();
        }
    }
}
